package WaiBao;

import java.util.Arrays;

public class ZhangYu {
    public static void main(String[] args) {
        String[] name = {"杨昊天(班长)", "李德龙(团支书)", "小李(学习委员)", "张家龙(文艺委员)", "李兴楠", "王德志", "李兆口", "王当", "李小崴", "张波", "张村发", "李姚凯",
                "张天爱", "李浩天", "王昊", "张翔宇", "王志宇", "李援朝", "张海", "季昌明", "高育良", "程度", "膏小青", "赵瑞龙", "高小琴", "小黑", "赵德贵", "邓超",
                "刘德华", "张宇(组织委员)"};//考生本人:张宇(组织委员)
        int[] age = {20,18, 19,20, 19, 21,19, 21, 21, 21, 19, 20, 23, 21, 21, 19, 18, 20, 18, 18, 19, 19, 20, 20, 20, 19,22,21,20, 19};//最后一位：考生年龄:19

        double[] yangyang1 = {75, 86, 84, 84, 89, 69, 74, 80, 84, 80, 81, 84, 85, 88, 88, 68, 70, 70, 76, 84, 92, 91, 95, 65, 75, 74, 94, 88, 84, 96};
        double[] yangyang2 = {86, 84, 90, 76, 74, 74, 79, 79, 81, 74, 70, 77, 80, 80, 80, 64, 76, 79, 64, 98, 72, 71, 95, 86, 76, 84, 84, 75, 84, 95};
        double[] yangyang3 = {90, 76, 84, 85, 74, 66, 68, 74, 84, 80, 73, 87, 85, 65, 85, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 87, 74, 75, 89, 97};

//        double honglou1;//代表每个学生的总分
//        double honglou2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            honglou1 =yangyang1[i] + yangyang2[i] +yangyang3[i];
//            honglou2 = (honglou1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + honglou1);
//            System.out.println(name[i] + "的平均分为:" + honglou2);
//        }


        double xiqu1 = 0,xiqu2 = 0;
        double[] wangdian = new double[30];
//        for (int i = 0; i < 30; i++) {
//            xiqu1= yangyang1[i] + yangyang2[i] +  yangyang3[i];
//            xiqu2 = (xiqu1* 1.0) / 3;
//            wangdian[i] = xiqu2;
//        }
//
//        for (int i = 0; i < wangdian.length - 1; i++) {
//            for (int j = 0; j <wangdian.length - i - 1; j++) {
//                if (wangdian[j] <wangdian[j + 1]) {
//                    double tep = wangdian[j];
//                    wangdian[j] =wangdian[j + 1];
//                    wangdian[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(wangdian[i]);
//        }


        double zhouyi1 = 0,zhouyi2 = 0,zhouyi3 = 0;//计算每门课的平均分
        double zhouer1 = 0,zhouer2 = 0,zhouer3 = 0;//计算每门课标准差
        double zhousan1 = 0,zhousan2 = 0,zhousan3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <yangyang1.length; i++) {
            he +=yangyang1[i];
        }
        zhouyi1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" + zhouyi1);
        double Sum = 0;
        for (int i = 0; i < yangyang2.length; i++) {
            Sum +=yangyang2[i];
        }
        zhouyi2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + zhouyi2);
        double sum = 0;
        for (int i = 0; i <yangyang3.length; i++) {
            sum +=yangyang3[i];
        }
        zhouyi3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + zhouyi3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <yangyang1.length; i++) {
            c1 += (yangyang1[i] - zhouyi1) * (yangyang1[i] - zhouyi1);
        }
        zhouer1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + zhouer1);
        for (int i = 0; i < yangyang2.length; i++) {
            c2 += (yangyang2[i] -zhouyi2) * (yangyang2[i] -zhouyi2);
        }
        zhouer2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +zhouer2);

        for (int i = 0; i <yangyang3.length; i++) {
            c3 += (yangyang3[i] -zhouyi3) * (yangyang3[i] -zhouyi3);
        }
        zhouer3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" + zhouer3);
////////////
        Arrays.sort(yangyang1);
        Arrays.sort(yangyang2);
        Arrays.sort(yangyang3);
        zhousan1 = (yangyang1[14] +yangyang2[15]) * 1.0 / 2;
        zhousan2 = (yangyang2[14] +yangyang2[15]) * 1.0 / 2;
        zhousan3 = (yangyang3[14] + yangyang3[15]) * 1.0 / 2;
        System.out.println("农业设施及环境调控的中位数为:" + zhousan1);
        System.out.println("农业设施设计与制造的中位数为:" + zhousan2);
        System.out.println("园艺植物设施栽培学的中位数为:" + zhousan3);


    }
}
